package com.duolebo.uteped_sdk.model;

import android.annotation.SuppressLint;
import android.content.ContentValues;
import android.database.Cursor;

import com.yc.nadalsdk.bean.FitnessOxygenData;

import java.util.ArrayList;

/**
 * @Author: wudapeng
 * @Date: 2023/12/25 20:12
 * @Description:
 */
public class Spo2Model extends BaseModel {
    public String calendarTime;
    public String calendar;
    private int time;
    private int oxygenValue;


    public Spo2Model(FitnessOxygenData data) {
        this.calendar = data.getCalendar();
        this.calendarTime = data.getCalendarTime();
        this.time = data.getTime();
        this.oxygenValue = data.getOxygenValue();
    }

    public Spo2Model(){}

    /**
     * BaseModel
     *
     * @param model model
     */
    Spo2Model(BaseModel model) {
        super(model);
    }

    @Override
    public void writeFieldValues(ContentValues values) {
        super.writeFieldValues(values);
        values.put(Spo2Fields.CALENDAR_TIME, calendarTime);
        values.put(Spo2Fields.CALENDAR, calendar);
        values.put(Spo2Fields.TIME, time);
        values.put(Spo2Fields.OXYGEN_VALUE, oxygenValue);
    }

    @SuppressLint("Range")
    @Override
    public void readFieldValues(Cursor c) {
        super.readFieldValues(c);
        calendarTime = c.getString(c.getColumnIndex(Spo2Fields.CALENDAR_TIME));
        calendar = c.getString(c.getColumnIndex(Spo2Fields.CALENDAR));
        time = c.getInt(c.getColumnIndex(Spo2Fields.TIME));
        oxygenValue = c.getInt(c.getColumnIndex(Spo2Fields.OXYGEN_VALUE));
    }

    @Override
    public void prepareFieldDefs(ArrayList<String> fieldDefs) {
        super.prepareFieldDefs(fieldDefs);
        fieldDefs.add(Spo2Fields.CALENDAR_TIME + FIELD_TYPE_TEXT);
        fieldDefs.add(Spo2Fields.CALENDAR + FIELD_TYPE_TEXT);
        fieldDefs.add(Spo2Fields.TIME + FIELD_TYPE_INTEGER);
        fieldDefs.add(Spo2Fields.OXYGEN_VALUE + FIELD_TYPE_INTEGER);
    }

    public static class Spo2Fields implements Fields {
        public static final String CALENDAR_TIME = "calendar_time";
        public static final String CALENDAR = "calendar";
        public static final String TIME = "time";
        public static final String OXYGEN_VALUE = "oxygen_value";
    }

    public String getCalendarTime() {
        return calendarTime;
    }

    public void setCalendarTime(String calendarTime) {
        this.calendarTime = calendarTime;
    }

    public String getCalendar() {
        return calendar;
    }

    public void setCalendar(String calendar) {
        this.calendar = calendar;
    }

    public int getTime() {
        return time;
    }

    public void setTime(int time) {
        this.time = time;
    }

    public int getOxygenValue() {
        return oxygenValue;
    }

    public void setOxygenValue(int oxygenValue) {
        this.oxygenValue = oxygenValue;
    }

}
